home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / cisco / cisco-expect.shar / cleanconfig < prev   
Text File  |  1992-08-07  |  546b  |  28 lines

  1. #!/usr/bin/perl
  2.  
  3. $file = $ARGV[0];
  4. $newfile = $file . ".new";
  5. die "No file specified\n" unless $file;
  6.  
  7. open(CFG, "<$file") || die "Can't open $file\n";
  8. open(NEWCFG, ">$newfile") || die "Can't open $newfile\n";
  9.  
  10. print NEWCFG <<"EOM";
  11. !
  12. ! Note: this file ($file) has had the passwords removed for
  13. !       security reasons.
  14. !
  15. EOM
  16. while (<CFG>) {
  17.     if (/^(enable-password|password)\s+/) {
  18.         print NEWCFG "! $1 CENSORED\n";
  19.         next;
  20.     }
  21.     print NEWCFG;
  22. }
  23. close(CFG);
  24. close(NEWCFG);
  25.  
  26. rename($newfile, $file) || die "Can't rename $newfile to $file: $!\n";
  27.  
  28.